package com.mypaper.list;

import com.mypaper.dag.DAG;
import com.mypaper.elem.TaskAttribute;


public class TaskInfo {
	public int taskSN;
	public OrderLinkedList childList;
	public OrderLinkedList directChildList;
	public OrderLinkedList parentList;
	public OrderLinkedList directParentList;
	
	public TaskInfo(){
		taskSN=0;
		childList=new OrderLinkedList();
		directChildList=new OrderLinkedList();
		parentList=new OrderLinkedList();
		directParentList=new OrderLinkedList();
	}
	
	public TaskInfo(DAG dag, int taskSN){
	
		int taskNum=dag.vertexNum;
		float[][] edgeWeight=dag.edgeWeight;
		
		this.taskSN=taskSN;
		childList=new OrderLinkedList();
		parentList=new OrderLinkedList();
		directChildList=new OrderLinkedList();
		directParentList=new OrderLinkedList();
		
		for(int j=0; j<taskNum; j++){
			if(edgeWeight[j][this.taskSN]>0){
				if(directParentList.isExisted(new TaskAttribute(j, 0))==false){
					parentList.insertNode(new TaskAttribute(j, 0));
					directParentList.insertNode(new TaskAttribute(j, 0));
				}
				for(int k=0; k<taskNum; k++){
					if(edgeWeight[k][j]>0)
						if(parentList.isExisted(new TaskAttribute(k, 0))==false)
							parentList.insertNode(new TaskAttribute(k, 0));
				}	
			}
			if(edgeWeight[this.taskSN][j]>0){
				if(directChildList.isExisted(new TaskAttribute(j, 0))==false){
					childList.insertNode(new TaskAttribute(j, 0));
					directChildList.insertNode(new TaskAttribute(j, 0));
				}
				
				for(int k=0; k<taskNum; k++){
					if(edgeWeight[j][k]>0)
						if(childList.isExisted(new TaskAttribute(k, 0))==false)
							childList.insertNode(new TaskAttribute(k, 0));
				}
			}
		}
		
	
	}
}
